# import frida
# import sys
#
#
# def list_devices():
#     """列出所有可用设备"""
#     devices = frida.enumerate_devices()
#     print("可用设备列表:")
#     for device in devices:
#         print(f"Device ID: {device.id}, Name: {device.name}, Type: {device.type}")
#
#
# def connect_to_specific_device(device_id):
#     """连接到指定的设备"""
#     try:
#         # 通过设备ID获取设备
#         device = frida.get_device(device_id)
#
#         print(f"成功连接到设备: {device.name}")
#
#         # 枚举设备上的进程
#         print("\n--- 进程列表 ---")
#         processes = device.enumerate_processes()
#         for process in processes:
#             print(f"PID: {process.pid}, Name: {process.name}")
#
#             # 获取前台应用
#         try:
#             front_app = device.get_frontmost_application()
#             print("\n--- 前台应用 ---")
#             print(f"前台应用: {front_app}")
#         except Exception as front_app_error:
#             print(f"获取前台应用时出错: {front_app_error}")
#
#         return device
#
#     except Exception as e:
#         print(f"连接到设备 {device_id} 时发生错误: {e}")
#         return None
#
#
# def main():
#     # 首先列出所有可用设备
#     list_devices()
#
#     # 手动指定要连接的设备ID
#     device_id = input("\n请输入要连接的设备ID: ")
#
#     # 连接到指定设备
#     connected_device = connect_to_specific_device(device_id)
#
#     if connected_device:
#         # 可以进一步对设备进行操作
#         pass
#
#
# if __name__ == "__main__":
#     main()
#
# # com.carrefouruae.Carrefour-UAE
import frida


def find_foreground_app():
    device = frida.get_usb_device()
    apps = device.enumerate_applications()

    # 打印所有前台应用的详细信息
    for app in apps:
        if app.pid > 0:  # 正在运行的应用
            print(f"Name: {app.name}")
            print(f"Bundle ID: {app.identifier}")
            print(f"PID: {app.pid}")
            print("---")


find_foreground_app()
import frida
import sys  

def list_devices():  
    """列出所有可用设备"""  
    devices = frida.enumerate_devices()  
    print("可用设备列表:")  
    for device in devices:  
        print(f"Device ID: {device.id}, Name: {device.name}, Type: {device.type}")  

def connect_to_specific_device(device_id):  
    """连接到指定的设备"""  
    try:  
        # 通过设备ID获取设备  
        device = frida.get_device(device_id)  
        
        print(f"成功连接到设备: {device.name}")  
        
        # 枚举设备上的进程  
        print("\n--- 进程列表 ---")  
        processes = device.enumerate_processes()  
        for process in processes:  
            print(f"PID: {process.pid}, Name: {process.name}")  
        
        # 获取前台应用  
        try:  
            front_app = device.get_frontmost_application()  
            print("\n--- 前台应用 ---")  
            print(f"前台应用: {front_app}")  
        except Exception as front_app_error:  
            print(f"获取前台应用时出错: {front_app_error}")  
        
        return device  
    
    except Exception as e:  
        print(f"连接到设备 {device_id} 时发生错误: {e}")  
        return None  

def main():  
    # 首先列出所有可用设备  
    list_devices()  
    
    # 手动指定要连接的设备ID  
    device_id = input("\n请输入要连接的设备ID: ")  
    
    # 连接到指定设备  
    connected_device = connect_to_specific_device(device_id)  
    
    if connected_device:  
        # 可以进一步对设备进行操作  
        pass  

if __name__ == "__main__":  
    main()


# com.carrefouruae.Carrefour-UAE  
# com.carrefouruae.Carrefour-UAE  
# com.maersk.trackandtrace.maerskline